<? FoundryView::includeTpl( 'adminMain:header' ) ?>

<script type="text/javascript" src="<?=Foundry::config('webpath')?>/javascript/admin/editToolBar.js"></script>
<script type="text/javascript" src="<?=Foundry::config('webpath')?>/javascript/admin/newsRules.js"></script>

<div id="mainContent">


	<h2>News</h2>
	
	<a href="<?=FoundryView::helperLinkTo('newsAdmin/post')?>" class="actionLink">
		<img src="<?=Foundry::config('webpath')?>/images/admin/add.png" />
		new post</a>
	<span id="actionMessage"></span>
	
	<div class="actionForm">
		<form method="post" action="<?=FoundryView::helperLinkTo('newsAdmin/post')?>/<?=$this->data['post']->uid?>">

		<div class="cellLeft">
	
			<input type="hidden" name="k" value="<?=$this->data['key']?>" />
			<label for="newsHeadline">Headline</label>
			<input type="text" name="newsHeadline" value="<?=$this->data['post']->headline?>" /><p />
			
			<label for="newsSubhead">Subhead</label>
			<input type="text" name="newsSubhead" value="<?=$this->data['post']->subhead?>" /><p />
			
			<label for="newsAbstract">Abstract</label>
			<div id="newsAbstractToolBar"></div>
			<script type="text/javascript">
				ToolBar.create( 'newsAbstractToolBar',
					'newsAbstract' );
			</script>

			<textarea rows="5" cols="55" name="newsAbstract" id="newsAbstract"><?=$this->data['post']->abstract?></textarea><p />
			
			<label for="newsContent">Content</label>
			<div id="newsContentToolBar"></div>
			<script type="text/javascript">
				ToolBar.create( 'newsContentToolBar',
					'newsContent' );
			</script>

			<textarea rows="20" cols="55" name="newsContent" id="newsContent"><?=$this->data['post']->content?></textarea><p />
			<p />
			<input type="submit" value="Save" />
			<a href="<?=FoundryView::helperLinkTo( 'newsAdmin/' )?>" class="cancelLink">Cancel</a>
		</div>
		<div class="cellRight">
			<label for="newsStatus">Publication Status</label>
			<input type="checkbox" name="newsPublished" value="1" <?php if( $this->data['post']->published ) : ?>checked="checked"<?php endif ?> />
			This post is published
			<p />

			<label for="newsStatus">Tags</label>
			<select name="newsTagID[]" multiple="multiple">
			<?php
			
				$tagModel = FoundryController::model( 'tag' );
				$tags = $tagModel->find( 'order by *name' );
				foreach( $tags as $tag ) {
					echo '<option value="'.$tag->uid.'"';
					
					if( in_array( $tag->uid, $this->data['postTags'] ) ) {
						echo ' selected="selected"';
					}
					
					echo '>'.$tag->name.'</option>';
				}
			?>
			</select><p />
			
			<label for="newsComments">Comments</label>
			<input type="checkbox" id="allowComments" name="allowComments" <?php if( $this->data['post']->allow_comments ) { echo 'checked="checked"'; } ?> value="1" />
			Allow commenting for this post<p />
			
			<div class="infoBumperStandard" id="commentChallengeContainer" <?php if( $this->data['post']->allow_comments != 1 ) { echo 'style="display: none;"'; } ?>>
				<input type="checkbox" id="moderate" name="moderate" <?php if( $this->data['post']->moderate ) { echo 'checked="checked"'; } ?> value="1" />
				Moderate comments in this post<p />
				<hr />
				You can set a challenge/response combination for this article. This may help to decrease comment spam.<br />
				Try to keep them simple:<br /><br />
				<b>Challenge:</b>
				<input type="text" name="commentChallenge" value="<?php if( $this->data['post']->challenge ) { echo $this->data['post']->challenge; } else { echo 'What color is a banana?'; } ?>" /><br />
				<b>Response:</b>
				<input type="text" name="commentResponse" value="<?php if( $this->data['post']->response ) { echo $this->data['post']->response; } else { echo 'yellow'; } ?>" /><br />
			</div>
			<br />
			
		</div>
		<br class="cellBottom" />
		
		</form>
	</div>	
	
</div>
<?php if( FoundryRequest::get( 'msg' ) == 'sv' ) : ?>
<script type="text/javascript">
	actionMessage( 'Post Saved' );
</script>
<?php endif ?>
<? FoundryView::includeTpl( 'adminMain:footer' ) ?>